//
//  NMPOModel.swift
//  NMPO
//
//  Created by PowerfullClean on 2023/10/31.
//

import UIKit
import ObjectMapper
import NetworkExtension

let nmpo_vpnStateChange_noti = NSNotification.Name.NEVPNStatusDidChange
let nmpo_vpnlistUpdate_noti = NSNotification.Name("nmpo_vpnlistUpdate_noti")
let nmpo_funIPINFOUpdate_noti = NSNotification.Name("nmpo_funIPINFOUpdate_noti")
enum NMPONetType: NSInteger {
    case nmpo_none = 0
    case nmpo_wifi
    case nmpo_cellular
    
}

enum NMPOSettingType: NSInteger {
    case nmpo_rate = 0
    case nmpo_share
    case nmpo_privacy
}

enum NMPOFuncType: NSInteger {
    case nmpo_connect = 0
    case nmpo_disConnect
    case nmpo_speed
    case nmpo_ip
    case nmpo_device
    var nmpo_title:String {
        switch self {
        case .nmpo_speed:
            return "Speed test"
        case .nmpo_ip:
            return "IP information"
        case .nmpo_device:
            return "Device information"
        default:
            return ""
        }
    }
}

@objc enum NMPOVpnStateType: NSInteger {
    /** @const NEVPNStatusInvalid The VPN is not configured. */
    case nmpo_invalid = 0
    
    /** @const NEVPNStatusDisconnected The VPN is disconnected. */
    case nmpo_disconnected = 1
    
    /** @const NEVPNStatusConnecting The VPN is connecting. */
    case nmpo_connecting = 2
    
    /** @const NEVPNStatusConnected The VPN is connected. */
    case nmpo_connected = 3
    
    /** @const NEVPNStatusReasserting The VPN is reconnecting following loss of underlying network connectivity. */
    case nmpo_reasserting = 4
    
    /** @const NEVPNStatusDisconnecting The VPN is disconnecting. */
    case nmpo_disconnecting = 5
    var nmpo_title:String {
        switch self {
        case .nmpo_invalid:
            return "nmpo_invalid"
        case .nmpo_disconnected:
            return "nmpo_disconnected"
        case .nmpo_connecting:
            return "nmpo_connecting"
        case .nmpo_connected:
            return "nmpo_connected"
        case .nmpo_reasserting:
            return "nmpo_reasserting"
        case .nmpo_disconnecting:
            return "nmpo_disconnecting"
        default:
            return ""
        }
    }
}

enum NMPOVPNStateClickType: NSInteger {
    case nmpo_none = 0
    case nmpo_connect
    case nmpo_disConnect
    case nmpo_disAndConnect
}

struct NMPOSettingModel {
    var nmpo_type: NMPOSettingType = .nmpo_rate
    var nmpo_title: String = ""
    var nmpo_icon: String = ""
}
//MARK: - nmpo result func
struct NMPOFuncModel {
    var nmpo_type: NMPOFuncType = .nmpo_speed
    var nmpo_title: String = ""
    var nmpo_icon: String = ""
}
//MARK: - nmpo ip
class NMPOIPScanModel: NSObject, Mappable, Codable {
    var nmpo_city: String = ""
    var nmpo_country: String = ""
    var nmpo_loction: String = ""
    var nmpo_region: String = ""
    override init() {
        
    }
    required init?(map: Map) {}
    func mapping(map: Map) {
        nmpo_city    <- map["city"]
        nmpo_loction         <- map["loc"]
        nmpo_country      <- map["country"]
        nmpo_region       <- map["region"]
    }
}
//MARK: - nmpo speed
class NMPOSpeedValueModel: NSObject {
    var nmpo_download: String = ""
    var nmpo_upload: String = ""
    var nmpo_ping: String = ""
    var nmpo_loss: String = ""
    var nmpo_jitter: String = ""
    
}

//MARK: - nmpo vpn
class NMPOVPNRequestModel : NSObject, Mappable, Codable {
    var nmpo_vzdgw: NSInteger = 0
    var nmpo_crkZQ:NMPOVPNResContentModel = NMPOVPNResContentModel()
    override init() {
        
    }
    required init?(map: Map) {}
    func mapping(map: Map) {
        nmpo_vzdgw    <- map["Vzdgw"]
        nmpo_crkZQ    <- map["crkZQ"]
    }
}

class NMPOVPNResContentModel : NSObject, Mappable, Codable {
    var nmpo_lAoKn: String = "" //用户名
    var nmpo_wxFdL: String = "" //密码
    var nmpo_eksjN: Int = 0 //开始端口
    var nmpo_zRfuV: Int = 0 //结束端口
    var nmpo_qlHTP:[NMPOVPNResServerModel] = [NMPOVPNResServerModel]()
    override init() {
        
    }
    required init?(map: Map) {}
    func mapping(map: Map) {
        nmpo_lAoKn    <- map["LAoKn"]
        nmpo_wxFdL    <- map["wxFdL"]
        nmpo_eksjN    <- map["eksjN"]
        nmpo_zRfuV    <- map["ZRfuV"]
        nmpo_qlHTP    <- map["qlHTP"]
    }
}

class NMPOVPNResServerModel : NSObject, Mappable, Codable {
    var nmpo_bTuIq: String = "" //地址
    var nmpo_cTvsK: String = "" //国家
    var nmpo_pingValue: NSInteger = 0
    var nmpo_select: Bool = false
    override init() {
        
    }
    required init?(map: Map) {}
    func mapping(map: Map) {
        nmpo_bTuIq    <- map["BTuIq"]
        nmpo_cTvsK    <- map["cTvsK"]
        nmpo_pingValue    <- map["nmpo_pingValue"]
        nmpo_select    <- map["nmpo_select"]
    }
}
//MARK: - func
enum NMPOFuncMainType: NSInteger {
    case nmpo_choose = 0
    case nmpo_func
    case nmpo_ipIfo
}
struct NMPOFuncMainModel {
    var nmpo_type: NMPOFuncMainType = .nmpo_choose
}
//MARK: - device
struct NMPODeviceModel {
    var nmpo_title: String = ""
    var nmpo_dec: String = ""
    init(nmpo_title: String, nmpo_dec: String) {
        self.nmpo_title = nmpo_title
        self.nmpo_dec = nmpo_dec
    }
}

